package com.scm.biz.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.scm.biz.bean.Constant;
import com.scm.biz.service.ConstantService;
import com.scm.core.bean.resp.RespBean;
import com.scm.core.bean.resp.RespPagination;

@Controller
@RequestMapping("/constant")
public class ConstantAction {
	
	@Resource
	private ConstantService constantService;

	public ConstantAction() {
		
	}
	
	@RequestMapping("/getConstantByCategory")
	@ResponseBody
	public RespBean<RespPagination<Constant>> getConstantByCategory(String category){
		RespBean<RespPagination<Constant>> respBean = new RespBean<RespPagination<Constant>>();
		RespPagination<Constant> respPagination = new RespPagination<Constant>();
		List<Constant> constants = constantService.getConstantByCategory(category);
		respPagination.setRows(constants);
		respBean.setBody(respPagination);
		return respBean;
		
	}
	
	/**
	 * 标签模糊查询，输入字符提示标签
	 * @param name 输入标签名 
	 * @param category 分类
	 * @return
	 */
	@RequestMapping("/doGetConstantByQuery")
	@ResponseBody
	public RespBean<RespPagination<String>> doGetConstantByName(String name,String category){
		RespBean<RespPagination<String>> respBean=new RespBean<RespPagination<String>>();
		RespPagination<String> respPagination=new RespPagination<String>();
		List<String> constants=constantService.getConstantNameByQuery(name, category);
		respPagination.setRows(constants);
		respBean.setBody(respPagination);
		return respBean;
	}
	
}
